﻿@using FwProject.Users.Dto
@using FwProject.Authorization.Users
@model UserEnterDto
@{
    ViewBag.Title = "编辑用户信息";
}
@section styles{
    <link href="~/Theme/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="~/Content/bootstrap-tagsinput.css" rel="stylesheet" />
    <link href="~/Scripts/fancybox-2.1.7/source/jquery.fancybox.css" rel="stylesheet" media="screen" />
}
<div class="row wrapper wrapper-content animated fadeInRight">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>@ViewBag.Title <small></small></h5>
                <div class="ibox-tools">
                    <a class="collapse-link">
                        <i class="fa fa-chevron-up"></i>
                    </a>
                </div>
            </div>
            <div class="ibox-content">
                <form id="form0" class="form-horizontal" action="/Users/EditUser?id=@Html.ViewContext.RouteData.Values["id"]" method="post" novalidate="novalidate" data-ajax="true" data-ajax-success="ReloadAjaxCallbackgoback" data-ajax-failure="FailureAjaxCallback" data-ajax-method="Post" role="form">
                    @Html.AntiForgeryToken()
                    <div class="row" style="margin-top:17px">
                        @Html.LabelFor(o => o.FactoryinfoId, new { @class = "control-label col-md-3" })
                        @Html.TextBoxFor(o => o.FactoryinfoId, new { @class = "hidden" })
                        <div class="col-lg-6">
                            <div class="input-group">
                                <input type="text" id="dropdown-factoryinfo" class="form-control" value="@Model.FactoryinfoName">
                                <div class="input-group-btn">
                                    <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                                        <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu dropdown-menu-right" id="r" role="menu" style="z-index: 9999;"></ul>
                                </div>

                            </div>
                        </div>
                        @Html.ValidationMessageFor(o => o.RoleNames)
                    </div>
                    <div class="form-group" style="margin-top:17px">
                        @Html.LabelFor(o => o.EmployeeType, new { @class = "control-label col-md-3" })
                        <div class="col-md-6">
                            <enums asp-enum="typeof(EmployeeType)" asp-name="EmployeeType" asp-value="@Model.EmployeeType.ToString()" class="form-control" asp-valuetype="1"></enums>
                            @*<select class="form-control" asp-items="@Html.GetEnumSelectList(typeof(EmployeeType))"></select>*@
                            @Html.ValidationMessageFor(o => o.EmployeeType)
                        </div>
                    </div>
                    @*<div class="form-group">
                            @Html.LabelFor(o => o.FactoryinfoId, new { @class = "control-label col-md-3" })
                            <div class="col-md-6">
                                @Html.DropDownListFor(o => o.FactoryinfoId, ViewBag.Factoryinfos as IEnumerable<SelectListItem>
                                    , new { @class = "form-control" })
                                    @Html.ValidationMessageFor(o => o.FactoryinfoId)
                            </div>
                        </div>*@
                    @*<div class="form-group" style="margin-top:17px">
                        @Html.LabelFor(o => o.UserName, new { @class = "control-label col-md-3" })
                        <div class="col-md-6">
                            @Html.TextBoxFor(o => o.UserName, new { @class = "form-control" })
                            @Html.ValidationMessageFor(o => o.UserName)
                        </div>
                    </div>*@
                    <div class="form-group">
                        @Html.LabelFor(o => o.Name, new { @class = "control-label col-md-3" })
                        <div class="col-md-6">
                            @Html.TextBoxFor(o => o.Name, new { @class = "form-control" })
                            @Html.ValidationMessageFor(o => o.Name)
                        </div>
                    </div>
                    @*<div class="form-group">
                        @Html.LabelFor(o => o.Surname, new { @class = "control-label col-md-3" })
                        <div class="col-md-6">
                            @Html.TextBoxFor(o => o.Surname, new { @class = "form-control" })
                            @Html.ValidationMessageFor(o => o.Surname)
                        </div>
                    </div>*@
                    <div class="form-group">
                        @Html.LabelFor(o => o.RoleNames, new { @class = "control-label col-md-3" })
                        <div class="col-md-6">
                            @Html.DropDownListFor(o => o.RoleNames, ViewBag.RoleNames as IEnumerable<SelectListItem>
                                , new { @class = "form-control" })
                            @Html.ValidationMessageFor(o => o.RoleNames)
                        </div>
                    </div>
                    <div class="form-group" style="margin-top:17px">
                        @Html.LabelFor(o => o.Mobile, new { @class = "control-label col-md-3" })
                        <div class="col-md-6">
                            @Html.TextBoxFor(o => o.Mobile, new { @class = "form-control" })
                            @Html.ValidationMessageFor(o => o.Mobile)
                        </div>
                        <span id="PhoneNumber-error"></span>
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(o => o.EmailAddress, new { @class = "control-label col-md-3" })
                        <div class="col-md-6">
                            @Html.TextBoxFor(o => o.EmailAddress, new { @class = "form-control" })
                            @Html.ValidationMessageFor(o => o.EmailAddress)
                        </div>
                    </div>
                    <div class="form-group">
                        @Html.LabelFor(o => o.NowAddress, new { @class = "control-label col-md-3" })
                        <div class="col-md-6">
                            @Html.TextBoxFor(o => o.NowAddress, new { @class = "form-control" })
                            @Html.ValidationMessageFor(o => o.NowAddress)
                        </div>
                    </div>

                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <button class="btn btn-primary" type="submit">保存内容</button>
                            <button class="btn btn-white" type="reset">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="~/Theme/js/content.min.js?v=1.0.0"></script>
    <script src="~/Theme/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/Scripts/bootstrap-tagsinput.js"></script>
    <script src="~/Theme/js/plugins/suggest/bootstrap-suggest2014.js"></script>
    <script src="~/Scripts/jquery.treegrid.min.js"></script>

    <script type="text/javascript">
        function ReloadAjaxCallbackgoback(data, successInfo) {
            CommonAjaxCallback(data, function () {
                top.closeAndRefreshTab("@Url.Action("Edit", new { id = Html.ViewContext.RouteData.Values["id"] })", "@Url.Action("Index")");
            }, successInfo);
        }
        $(document).ready(function () {
               $.getJSON("/Factory/GetAll").done(function (data) {
                CommonAjaxCallback(data, function () {
                    factorys = data.result;
                    bindSuggest(factorys);
                }, null);
            }).fail(function () {
                layer.msg('连接超时，获取司机信息失败！', {
                    icon: 2,
                    time: 2000
                });
            });

            $('.bootstrap-tagsinput input').width(1);
            $(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });

        });


    function bindSuggest(factorys) {
        if ($("#dropdown-factoryinfo") != undefined) {
            $role = $("#dropdown-factoryinfo").bsSuggest({
                effectiveFields: ["factoryName"],
                effectiveFieldsAlias: { "factoryName": "工厂名称" },
                searchFields: ["factoryName"],
                clearable: true,
                getDataMethod: "data",    //获取数据的方式，总是从 URL 获取
                //url: "/Factory/GetAll?keyword=",
                data: { value: factorys },
                idField: "id",
                keyField: "factoryName",
            }).on('onDataRequestSuccess', function (e, result) {
                console.log('onDataRequestSuccess: ', result);
            }).on('onSetSelectValue', function (e, keyword, data) {
                $("#FactoryinfoId").val(data.id);
                console.log('onSetSelectValue: ', keyword, data);
            }).on('onUnsetSelectValue', function () {
                console.log('onUnsetSelectValue');
            });
        }
    }


    </script>
}

